//
//  OverInfomationTableViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/8.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "OverInfomationTableViewCell.h"
@interface OverInfomationTableViewCell()<UITextFieldDelegate>
@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UILabel *titleLabel; // 标题
@end

@implementation OverInfomationTableViewCell
#pragma mark - UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField *)textField{
    if (self.getTextFieldClick) {
        self.getTextFieldClick(textField.text);
    }
}
- (void)setDataDic:(NSDictionary *)dataDic
{
    self.titleLabel.text = dataDic[@"titleName"];
    self.textField.text = dataDic[@"inputValue"];
//    if ([dataDic[@"titleName"] isEqualToString:@"地址"] || [dataDic[@"titleName"] isEqualToString:@"证件上传"] || [dataDic[@"titleName"] isEqualToString:@"公司地址"]) {
//        self.textField.hidden = YES;
//    }
    if ([dataDic[@"titleName"] isEqualToString:@"证件上传"]) {
        self.textField.hidden = YES;
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsZero;
        
        [self.contentView addSubview:self.leftImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.textField];
        
        __weak typeof(self)weakself = self;
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY);
            make.left.equalTo(weakself.mas_left).offset(20 / WIDTH_6S_SCALE);
            make.height.mas_offset(40 / WIDTH_6S_SCALE);
            make.width.mas_offset(80 / WIDTH_6S_SCALE);
        }];
        UIView *lineView = [[UIView alloc]init];
        lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakself.mas_bottom).offset(0.5);
            make.left.right.equalTo(weakself);
            make.height.mas_equalTo(0.5);
        }];
        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
            make.height.mas_offset(17 / WIDTH_6S_SCALE);
            make.width.mas_offset(10 / WIDTH_6S_SCALE);
        }];
        [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY);
            make.right.equalTo(weakself.leftImageView.mas_left).offset(-10 / WIDTH_6S_SCALE);
            make.height.mas_offset(40 / WIDTH_6S_SCALE);
            make.width.mas_offset(200 / WIDTH_6S_SCALE);
        }];
    }
    return self;
}

#pragma mark - init
- (UIImageView *)leftImageView
{
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc]init];
        _leftImageView.backgroundColor = [UIColor clearColor];
        _leftImageView.image = [UIImage imageNamed:@"list_wjleftimg"];
    }
    return _leftImageView;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = DEF_FontSize_14;
        [_titleLabel sizeToFit];
        _titleLabel.text = @"相识有缘304";
    }
    return _titleLabel;
}
- (UITextField *)textField{
    if (!_textField) {
        _textField = [[UITextField alloc]init];
        _textField.backgroundColor = [UIColor clearColor];
        UIColor *color = getColor(mainColor);
        _textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请填写" attributes:@{NSForegroundColorAttributeName: color}];
        _textField.delegate = self;
//        _textField.placeholder = @"请填写";
        _textField.textColor = getColor(mainColor);
        _textField.textAlignment = NSTextAlignmentRight;
        _textField.font = DEF_FontSize_14;
    }
    return _textField;
}
@end

